<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="{$_C.hy_path}css/amazeui.min.css" />
		<link rel="stylesheet" type="text/css" href="{$_C.hy_path}css/hy.admin.css" />
	</head>

	<body>
		<div class="am-g">
			{include file='../Common/hy_header.html'}
			<div class="am-u-md-8 am-u-end">
				<form class="am-form am-form-horizontal hy-js-form">
					<div class="am-form-group">
						<label for="user-name" class="am-u-sm-3 am-form-label">发送email方式</label>
						<div class="am-u-sm-9">
							<div class="am-btn-group" data-am-button="">
								<label class="am-btn am-btn-default am-btn-xs  {if $setting.email_type}{if $setting.email_type eq 1} am-active{else}{/if}{else} am-active{/if}">
									<input type="radio" name="email_type" value="1" {if $setting.email_type}{if $setting.email_type eq 1} checked="checked" {else}{/if}{else} checked="checked" {/if} id="option1"> 第三方SMTP
								</label>
								<label class="am-btn am-btn-default am-btn-xs  {if $setting.email_type eq 2}am-active{else}{/if}">
									<input type="radio" name="email_type" {if $setting.email_type eq 2} checked="checked" {else}{/if} value="2" id="option2">服务器内置SMTP
								</label>
							</div>
						</div>
					</div>
					<div class="am-form-group">
						<label for="user-name" class="am-u-sm-3 am-form-label">SMTP服务器地址</label>
						<div class="am-u-sm-9">
							<input type="text" name="smtp" value="{$setting['smtp']}" placeholder="如:smtp.qq.com">
						</div>
					</div>
					<div class="am-form-group">
						<label for="user-name" class="am-u-sm-3 am-form-label">账户名</label>
						<div class="am-u-sm-9">
							<input type="text" name="smtp_username" value="{$setting['smtp_username']}">
						</div>
					</div>
					<div class="am-form-group">
						<label for="user-name" class="am-u-sm-3 am-form-label">密码</label>
						<div class="am-u-sm-9">
							<input type="password" name="smtp_password" value="{$setting['smtp_password']}">
						</div>
					</div>
					<div class="am-form-group">
						<label for="user-name" class="am-u-sm-3 am-form-label">邮件发送地址</label>
						<div class="am-u-sm-9">
							<input type="text" name="smtp_email" value="{$setting['smtp_email']}" placeholder="如：admin@qq.com">
						</div>
					</div>
					<div class="am-form-group">
						<label for="user-name" class="am-u-sm-3 am-form-label">测试邮件地址</label>
						<div class="am-u-sm-9">
							<input type="text" class="test_email" value="" placeholder="如：admin@qq.com">
						</div>
					</div>
					<div class="am-form-group">
						<div class="am-u-sm-9 am-u-sm-push-3">
							<button type="button" class="am-btn am-btn-primary hy-js-submit">{$_L.SAVE}</button>
							<button type="button" class="am-btn am-btn-primary hy-js-testemail">发送测试邮件</button>
						</div>
					</div>
				</form>
			</div>
		</div>
		{include file='../Common/hy_footer.html'}
		<script type="text/javascript">
		$('.hy-js-testemail').click(function(e){
			e.preventDefault();
			var smtp=$('input[name=smtp]').val();
			var smtp_username=$('input[name=smtp_username]').val();
			var smtp_password=$('input[name=smtp_password]').val();
			var smtp_email=$('input[name=smtp_email]').val();
			var test_email=$('input.test_email').val();
			
			$.post('index.php?g=admin&m=sys&a=testemail',{ smtp:smtp,smtp_username:smtp_username,smtp_password:smtp_password,smtp_email:smtp_email,test_email:test_email},function(result){
				showMsg(result.content,result.error);
			},'json')
		})
			   hy_submit('index.php?g=admin&m=sys&a=saveSetting');
		</script>
	</body>

</html>